<template>
  <el-dialog title="审核通过" :visible.sync="isShow" width="500px"
             @close="$emit('update:isShowDialog', false)">
    <el-form label-position="right" ref="info" :model="productInfo" label-width="110px">
      <el-form-item label="商品名称:">
        <span>{{productInfo.productName}}</span>
      </el-form-item>
      <el-form-item label="供应商名称:">
        <span>{{productInfo.enterpriseName}}</span>
      </el-form-item>
    </el-form>
    <p class="c-red" style="padding: 0 30px;">注意：您正在对商品进行审核通过操作，审核通过后此商品将自动上架并可交易，请您确认。</p>
    <div class="footer text-center">
      <el-button @click="isShow = false">取 消</el-button>
      <el-button type="primary" @click="updateProductStatus">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
  export default {
    name: "updateTProductStatusOrPass",
    props: {
      isShowDialog: {
        type: Boolean,
        default: false
      },
      pInfo:{
        default:()=>{
          return{
            productName:"",
            enterpriseName:"",
            id:null
          }
        }
      }
    },
    data() {
      return {
        isShow: this.isShowDialog,
        productInfo:{...this.pInfo}
      }
    },
    watch: {
      isShowDialog(val) {
        this.isShow = val
      },
      pInfo(val) {
        this.productInfo = {...val}
      }
    },
    methods: {
      updateProductStatus() {
        ajax.post(apis.productAudit.updateTProductStatusOrPass, {id:this.productInfo.id})
          .then(res => {
            if (res.success === true) {
              this.$message({
                message: res.message,
                type: 'success'
              });
              this.isShow = false
              this.$emit("getProductList")
            } else {
              this.$message({
                message: res.message,
                type: 'error'
              })
            }
          })
      }
    },
    created() {
    }
  }
</script>

<style lang="scss" scoped>
.footer{
  margin-top: 40px;
}
</style>
